﻿@model CanDichVU.Models.LocalPasswordModel
@{
    AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestChangePass"
    };
}

<div class="formdangky divChangePass">
    @using (Ajax.BeginForm("ChangePass", "Account", null, ajaxOpts, new { enctype = "multipart/form-data", name = "frm_register", id = "frm_register" }))
    {
        <ul class="formreg">
            <li></li>
            <li class="warning-area-changePass"></li>
            <li>
                <label class="left">Mật khẩu cũ</label>
                <span class="right">
                    @Html.PasswordFor(model => model.OldPassword, new { name = "Pass", @placeholder = "Mật khẩu cũ (bắt buộc từ 3 -> 9 ký tự)", value = "", style = "width: 86%;" })
                </span>
            </li>
            <li>
                <label class="left">Mật khẩu mới</label>
                <span class="right">
                    @Html.PasswordFor(model => model.NewPassword, new { name = "NewPassword", @placeholder = "Mật khẩu mới (bắt buộc từ 3 -> 9 ký tự)", value = "", style = "width: 86%;" })
                    <span id="email-result-check"></span>
                </span>
            </li>
            <li class="line">
                <label class="left">Nhập lại mật khẩu mới</label>
                <span class="right">
                    @Html.PasswordFor(model => model.ConfirmPassword, new { name = "ConfirmPassword", @placeholder = "Nhập lại mật khẩu mới", value = "", style = "width: 86%;" })
                </span>
            </li>
            <li class="fone_num">
                        <div class="clear"></div>
                         <div class="right">
                            @Html.Partial("_Captcha", new CanDichVU.Models.Captcha())
                            @Html.Partial("_InvisibleCaptcha", new CanDichVU.Models.InvisibleCaptcha())
                         </div>
                    </li>
            <li class="clear"></li>
            <li class="line"><span class="left">&nbsp;</span> <span class="right">
                        <input type="submit" style="border: 0;" onclick="return loadmaskloadingChangePass();" class="btnsubmit" value="Thay Đổi mật khẩu" name=""></span>
                    </li>
        </ul>
    }
</div>

<link href="~/Scripts/jquery-loadmask/jquery.loadmask.css" rel="stylesheet" />
<script src="~/Scripts/jquery-loadmask/jquery.loadmask.js"></script>
<script type="text/javascript">

    function loadmaskloadingChangePass() {
        $(".divChangePass").mask("Dữ liệu đang xử lý...", 500);
    }


    function completedAjaxRequestChangePass(obj) {
        var returnObj = eval('(' + obj.responseText + ')');
        if (returnObj.Status == "success") {
            $(".divChangePass").unmask();
            makeSccuessHighlightChangePass(returnObj.Message);

        } else {
            makeErrorHighlightChangePass(returnObj.Message);
            $(".divChangePass").unmask();
        }
        return false;
    }

    function makeErrorHighlightChangePass(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Lỗi: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-changePass");
        $highlight.delay(4000).fadeOut(500);

    }

    function makeSccuessHighlightChangePass(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Thành công: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-changePass");
        $highlight.delay(4000).fadeOut(500);

    }

</script>
